<?php

namespace Frieza\Modules\Position\Actions;

use Doraemon\model\AdmOperateLog;
use Encore\Admin\Actions\RowAction;
use Encore\Admin\Facades\Admin;
use Illuminate\Http\Request;
use Doraemon\model\AdmRecommendUser;
use Doraemon\model\AdmBestUser;
use Doraemon\model\Member;
use Doraemon\cache\User as CacheUser;

class DeleteUserCache extends RowAction
{
    public $name = '清除用户缓存信息';
    const TOAST_ALERT = '确定清除该用户信息的缓存数据吗?';

    public function handle($uid)
    {
        CacheUser::deleteUserInfo($uid);
        return $this->response()->success('已清除该用户缓存信息');
    }

    public function retrieveModel(Request $request)
    {
        if (!$key = $request->get('_key')) {
            return false;
        }

        return $key;
    }

    public function dialog()
    {
        $this->confirm(self::TOAST_ALERT);
    }
}
